package bd403.UIComponents;

import bd403.Backend.Login;
import bd403.namespace.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

/* SplashScreen for the application. Includes the BrewDawg Logo and space for
 * advertisement.
 * Main author: Brenden
 */

public class SplashScreen extends Activity {
	protected boolean active = true;
	protected int splashTime = 5000; // time to display the splash screen in MS
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
     
        // thread for displaying the SplashScreen
        Thread splashTread = new Thread() {
            @Override
            public void run() {
                try {
                    int waited = 0;
                    while (active && (waited < splashTime)) {
                        sleep(100);
                        if (active) {
                            waited += 100;
                        }
                    }
                } catch(InterruptedException e) {
                    // do nothing
                } finally {
                	// transition to the Login page for the application
                    startActivity(new Intent(getApplicationContext(), Login.class));
                    finish();
                }
            }
        };
        splashTread.start();
    }
}
